package org.wevil.util;

import java.util.regex.Pattern;

/**
 * 正则表达式
 *
 * @author wanglei
 * @since 2022/2/27
 */
public class RegexUtil {

    /**
     * 校验车牌
     *
     * @param number 车牌号。示例：新AC2N82
     * @author wevil
     * @since 2023/9/28
     */
    public static boolean verifyPlate(String number) {
        String regex = "^?:[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领 A-Z]{1}[A-HJ-NP-Z]{1}(?:(?:[0-9]{5}[DF])|(?:[DF](?:[A-HJ-NP-Z0-9])[0-9]{4}))|(?:[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领 A-Z]{1}[A-Z]{1}[A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9 挂学警港澳]{1})$";
        return Pattern.matches(regex, number);
    }

    /**
     * 去除字符串里的中文
     *
     * @author wevil
     * @since 2023/10/17
     */
    public static String removeChinese(String str) {
        return str.replaceAll("[^(\\\\u4e00-\\\\u9fa5)]", "");
    }
}
